﻿using System;
using System.Collections.Generic;
using System.Linq;

using System.Text;
using System.Threading.Tasks;
using Business.EditOrder;
using Business.EditOrderUC;
using Microsoft.Practices.Unity;
using Model.Entities;
using Data;
using Nethouse.Lib.Mvp;
using Nethouse.Lib.Resolver;

namespace ObjectRepository
{
    public class UnityResolver : IResolver
    {
        private IUnityContainer container;

        public UnityResolver()
        {
            CreateContainer();
        }

        private void CreateContainer()
        {
            container = new UnityContainer();

            container.RegisterType<ISampleContext, SampleContext>();

            container.RegisterType<IPresenter<IEditOrderView>, EditOrderPresenter>();

            container.RegisterType<IPresenter<ISelectOrderView>, SelectOrderPresenter>();
            container.RegisterType<IPresenter<IShowOrderView>, ShowOrderPresenter>();

            container.RegisterType <IRepository<Company>, Repository<Company>>();
            container.RegisterType<IRepository<Order>, Repository<Order>>();
        }

        public TType Resolve<TType>()
        {
                return container.Resolve<TType>();
        }
    }
}
